<h2>Bolsa de Compras</h2>
<?php use_helper('Number','Form','Javascript')?>
<?php if ($sf_user->hasFlash('msj')): ?>
  <div class="mensaje_flash">
    <?php echo $sf_user->getFlash('msj') ?>
  </div>
<?php endif; ?>
<?php $articulosList = $sf_user->getAttribute('articulos')?>
<?php $cantidadList = $sf_user->getAttribute('cantidad')?>
<?php $totalList = $sf_user->getAttribute('total')?>
<?php echo form_tag("https://www.sandbox.paypal.com/cgi-bin/webscr",array("target"=>"paypal"))?>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<table class="bolsa_lista" border="0">
  <thead>
    <tr>
      <th>Clave</th>
      <th>Nombre</th>
      <th>Precio</th>
      <th>Cantidad</th>
      <th>Importe</th>
      <th>Borrar</th>
    </tr>
  </thead>
  <tbody>
  <?php if(isset($articulosList)):?>
    <?php $nArt = 1;?>
  <?php foreach($articulosList as $articulo): ?>
    <?php $art = ProductsPeer::retrieveByPK($articulo['id'])?>
    <?php //$tallas = explode(";",$art->getTalla())?>
    <?php $colores = ArticuloPeer::getColores($articulo['codigo'])?>
      <tr>
        <td><?php echo $art->getCode()?></td>
        <td><?php echo $art->getName()?>
        <?php // if ($articulo['color']):?>
           <?php // echo $articulo['color'];?>
        <?php //endif;?>
        <?php //if ($articulo['talla']):?>
           <?php //echo $articulo['talla'];?>
        <?php //endif;?>
        </td>
        <td><?php echo format_currency($art->getPricesell(),"$")?></td>
        <td>
        <?php if_javascript();?>
	        <?php echo input_tag("cantidad_{$articulo['id']}",$articulo['cantidad'],array("size"=>3))?>
	        <?php echo link_to_function("Actualizar","location.href='bolsa/actualizar?art={$articulo['id']}&cantidad='+\$('cantidad_{$articulo['id']}').value")?>
        <?php end_if_javascript();?>
        <noscript>
          <?php echo input_hidden_tag("cantidad_{$articulo['id']}",$articulo['cantidad'])?>
          <?php echo $articulo['cantidad']?>
          
        </noscript>
        </td>        
        <td><?php echo format_currency( $articulo['cantidad']* $art->getPricesell(),"$" )?></td>
        <td><?php echo link_to(image_tag("icons/delete.png"),"bolsa/delete?id={$articulo['id']}")?></td>
        <?php echo input_hidden_tag("item_name_$nArt",$art->getCode())?>
        <?php echo input_hidden_tag("item_number_$nArt",$art->getCode())?>
        <?php echo input_hidden_tag("amount_$nArt",$art->getPricesell())?>
        <?php echo input_hidden_tag("quantity_$nArt",$articulo['cantidad'])?>
        <?php //if ($articulo['color']):?>
          <?php //echo input_hidden_tag("on0_$nArt","Color")?>
          <?php //echo input_hidden_tag("os0_$nArt",$articulo['color'])?>
        <?php //endif?>
        <?php //if ($articulo['talla']):?>
          <?php //echo input_hidden_tag("on1_$nArt","Talla")?>
          <?php //echo input_hidden_tag("os1_$nArt",$articulo['talla'])?>
        <?php // endif?>
      </tr>
      <?php $nArt++;?>
  <?php endforeach;?>
  <?php endif;?>
  </tbody>
  <tfoot>
    <tr>
      <td colspan="4">&nbsp;</td>
      <td align="right">Sub-Total:</td>
      <td align="right"><?php echo format_currency($totalList,"$")?></td>
    </tr>
    <tr>
      <td colspan="4"></td>
      <td align="right">IVA:</td>
      <td align="right"><?php echo format_currency($totalList * 0.15,"$")?></td>
    </tr>
    <tr>
      <td colspan="4"></td>
      <td align="right"><strong>Total:</strong></td>
      <td align="right"><?php echo format_currency(($totalList * 0.15)+$totalList,"$")?></td>
    </tr>
  </tfoot>
</table>
<input type="hidden" name="cancel_return" value="http://tvpv/index.php/bolsa/index">
<input type="hidden" name="return" value="http://tvpv/frontend_dev.php/bolsa/pagado">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="currency_code" value="MXN">
<input type="hidden" name="tax_cart" value=<?php echo "\"".format_currency(($totalList*0.15),"")."\"" ?>>
<input type="hidden" name="business" value="wario7_1229458428_biz@yahoo.com.mx">
<input type="hidden" name="charset" value="utf8">
<input type="image" src="https://www.sandbox.paypal.com/es_XC/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="">

<?php  echo submit_tag("Pagar")?>
</form>
